<?php
function checkMain($TID,$p)
{
	global $Proxies,$threads,$threadsR,$args,$MTID,$Stats,$PostedThreads,$ProxiesAlive,$FlagLimitReached;
	foreach($Proxies as $i => $proxy)
	{
		AddThread("Check $i",'checkThread',array());
	}
}
function checkThread($TID,$p)
{
	global $threads,$Threads,$ThreadProxy,$ThreadID,$PostSets,$args,$proxy,$MTID,$FlagLimitReached;
	if (!isset($Threads[$TID]['proxy']))
	{
		ProxyGet();
	}
	if ($p['task'] != 'done')
	{
		$curl = GetChanCaptchaUrl(0,$args['board']);
		DoHTTPRequestPM(array(
			'url'		=> $curl,
			'ref'		=> GetPageUrl(0,$args['board']),
			'proxytype'	=> $proxy['proxytype'],
			'proxy'		=> $proxy['proxy'],
			'timeout'	=> $args['timeout'],
			'ua'		=> $useragents[$args['user-agent']],
			'params'	=> array("task"=>"done"),
			'debug'		=> ($args['debug']>2)?($args['debug']-2):0,
			));
	}
	else
	{
		if ($p['result'] OR !strpos($p['header'],'image'))
		{
			if (!ProxyReportError())
			{
				QueueThread($TID,0,'checkThread',array());
			}
		}
		else
		{
			echo "$proxy[proxy]\r\n";
			QueueThread($TID,0,'checkThread',array());
			/*$fp = fopen($args['file'],'a');
			fwrite($fp,"$proxy[proxy]\r\n");
			fclose($fp);*/
		}
	}
}
?>